package com.example.search.controller;

import com.example.common.dtos.ResponseResult;
import com.example.search.eneity.dto.UserSearchDto;
import com.example.search.service.ArticleSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/search")
@Api(tags = "ElasticSearch搜索控制器")
public class ArticleSearchController {
    @Autowired
    private ArticleSearchService articleSearchService;
    @ApiOperation(value = "搜索匹配图书")
    @PostMapping("/searchBook")
    public ResponseResult search(@RequestBody UserSearchDto dto) throws IOException {
        return articleSearchService.search(dto);
    }

    @GetMapping
    public ResponseResult searchAll() throws IOException {
        return articleSearchService.searchAll();
    }
}